//
//  HJSettlementAdditionalItemsViewCell.m
//  GAMCAfterSales
//
//  Created by 贺佳 on 2018/5/17.
//  Copyright © 2018年 glendale. All rights reserved.
//

#import "HJSettlementAdditionalItemsViewCell.h"

@implementation HJSettlementAdditionalItemsViewCell

UITablecellM(@"HJSettlementAdditionalItemsViewCell")
-(void)setUI{
    self.selectionStyle=UITableViewCellSelectionStyleNone;
    for (int i=0; i<6; i++) {
        UILabel *titlelabel = [[UILabel alloc]init];
        titlelabel.backgroundColor = [UIColor clearColor];
        titlelabel.textColor = [UIColor grayColor];
        titlelabel.numberOfLines=0;
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:14];
        [titlelabel setTextAlignment:NSTextAlignmentCenter];
        [self.contentView addSubview:titlelabel];
        titlelabel.userInteractionEnabled=YES;
    }
}
-(void)setRepairSettlementAdditemModel:(HJRepairSettlementAdditemModel *)repairSettlementAdditemModel
{
    _repairSettlementAdditemModel=repairSettlementAdditemModel;
    int i =0;
    for (UILabel*label in self.contentView.subviews) {
        switch (i) {
            case 0:
                
                break;
            case 1:
                label.text=repairSettlementAdditemModel.ADD_ITEM_CODE;
                break;
            case 2:
                label.text=repairSettlementAdditemModel.ADD_ITEM_NAME;
                break;
            case 3:
                label.text=repairSettlementAdditemModel.ADD_ITEM_AMOUNT;
                break;
            case 4:
                label.text=repairSettlementAdditemModel.DISCOUNT;
                break;
            case 5:
               
            {
                float  amount=[repairSettlementAdditemModel.ADD_ITEM_AMOUNT  floatValue];
                float discount=[repairSettlementAdditemModel.DISCOUNT floatValue];
                float price=amount*(1-discount);
                label.text=[NSString stringWithFormat:@"%.2f",price];
            }
                break;       
            default:
                break;
        }
        i++;
    }
}
-(void)setIndePath:(NSIndexPath *)indePath
{
    _indePath=indePath;
    UILabel*label=self.contentView.subviews[0];
    label.text=[NSString stringWithFormat:@"%zd",indePath.row+1];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat w=self.contentView.mj_w/self.contentView.subviews.count;
    int i=0;
    for (UIView*subView in self.contentView.subviews) {
        subView.frame=CGRectMake(i*w, 0, w, self.contentView.mj_h);
        i++;
    }
}

@end
